﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="save.aspx.cs" Inherits="H2.NET.Web.BI.Report.save" %>
<%@ Register Assembly="H2.NET.Controls" Namespace="H2.NET.Controls" TagPrefix="H2" %>
<style>
    .hidTr {
        display:none;
    }
</style>
<script type="text/javascript">
    $(function () {
        $(".isPub", $.pdialog.getCurrent()).click(function () {
            if ($(this).attr("checked") == "checked") {
                $(".hidTr", $.pdialog.getCurrent()).show();
            } else {
                $(".hidTr", $.pdialog.getCurrent()).val("").hide();
            }
        });
        if ("<%:template%>") {
            $("#txt_cfg_group", $.pdialog.getCurrent()).val("<%:template!=null?template.permission:""%>");
        }
    });

    function submitTemplate() {
        if (!$.trim($("#temName",$.pdialog.getCurrent()).val())) {
            alertMsg.error("请填写模版名称！");
            return false;
        }
        else if (($(".isPub", $.pdialog.getCurrent()).attr("checked") == "checked") && !$.trim($("#txt_cfg_group", $.pdialog.getCurrent()).val())) {
            alertMsg.error("请选择权限工作组！");
        }
        else {
            saveTemplate();
        }
    }

    function winOpenPopup(strURL, str_width, str_height, str_value, str_element, str_postback, str_multiple) {
        try {
            var var_time = new Date();
            var winoption = "dialogWidth=" + (parseInt(str_width) + 18) + "px;dialogHeight=" + str_height + "px;dialogLeft: status:no; directories:yes;scrollbars:auto;Resizable=yes;";
            var tmp = window.showModalDialog(strURL + "&vt=" + var_time, '', winoption);
            if (tmp != null && tmp != "" && tmp != undefined) {
                var o = eval('(' + tmp + ')');
                if ($("#txt_cfg_group", $.pdialog.getCurrent()).val().indexOf(eval("o." + str_value) + ",") >= 0) {
                    return;
                }
                //是否多选
                if (str_multiple == "0") {
                    document.getElementById(str_element).value = eval("o." + str_value);
                } else {
                    document.getElementById(str_element).value = document.getElementById(str_element).value + eval("o." + str_value) + ",";
                }

                //是否Postback
                if (str_postback == "1") {
                    //document.getElementById(str_element).onchange();
                    __doPostBack("change:" + document.getElementById(str_element).value, "");
                }
            }
        } catch (e) {
        }
    }
</script>
<form runat="server">
<div class="pageContent">
    <div class="pageFormContent" layouth="50">
       <table class="formTable">
           <tr>
               <th>
                   模版名称：
               </th>
               <td>
                   <input type="text" id="temName" class="required" style="width:95%" value="<%:template==null?"":(string.IsNullOrEmpty(cp)?template.name:"")%>"/>
               </td>
           </tr>
           <tr>
               <th>
                   共享：
               </th>
               <td>
                   <input type="checkbox" class="isPub" value="true" <%:template==null||template.pub==false?"":"checked" %> title="选中共享模版"/>
               </td>
           </tr>
           <tr class="hidTr" <%:template==null||template.pub==false?"":"style=display:table-row" %>>
               <th>
                   权限工作组：
               </th>
               <td>
                   <H2:Dialog ID="txt_cfg_group" ReadOnly title="双击弹出选择页面" runat="server" Width="250px"></H2:Dialog>
               </td>
           </tr>
       </table>
    </div>
    <div class="formBar">
        <ul>
            <li>
                <div class="buttonActive">
                    <div class="buttonContent">
                        <button type="button" onclick="submitTemplate()">保存数据</button></div>
                </div>
            </li>
            <li>
                <div class="button">
                    <div class="buttonContent">
                        <button type="button" class="close">关闭窗口</button></div>
                </div>
            </li>
        </ul>
    </div>
</div>
</form>
